﻿@using ControlGallery.Views

<Shell>
    <FlyoutItem Title="Main">
        <Tab Title="Gallery">
            <ShellContent>
                <PlaygroundList />
            </ShellContent>
        </Tab>
        <Tab Title="Shell Properties">
            <ShellPropertiesPlayground />
        </Tab>
        <Tab Title="Add/Remove">
            <ContentPage Title="Adder">
                <StackLayout>
                    <Button OnClick="AddTab">Add Tab</Button>
                    <Button IsEnabled="(tabCount > 1)" OnClick="RemoveTab">Remove tab</Button>
                    <Button OnClick="AddMenuItem">Add MenuItem</Button>
                    <Button IsEnabled="(menuItemCount > 0)" OnClick="RemoveMenuItem">Remove MenuItem</Button>
                </StackLayout>
            </ContentPage>
        </Tab>

        @for (int i = 0; i < tabCount; i++)
        {
            var currentIndex = i;
            <ShellTab Title="@($"Tab #{currentIndex + 1}")" />
        }
    </FlyoutItem>

    @for (int i = 0; i < menuItemCount; i++)
    {
        <MenuItem Text="@($"MenuItem #{i + 1}")" />
    }
</Shell>

@code {
    int tabCount = 1;
    int menuItemCount = 2;

    void AddTab()
    {
        tabCount++;
    }

    void RemoveTab()
    {
        if (tabCount > 1)
        {
            tabCount--;
        }
    }

    void AddMenuItem()
    {
        menuItemCount++;
    }

    void RemoveMenuItem()
    {
        if (menuItemCount > 0)
        {
            menuItemCount--;
        }
    }
}
